const express = require('express');
const app = express();
app.listen(3000, () => { console.log('服务器已开启') });
const session = require('cookie-session');//引入session模块

//开启session功能
app.use(session({
    keys: ['keys']
}))

//使用session工能,存信息
app.get('/login', (req, res) => {
    //session
    if (true) {
        req.session.username = '张三';
        req.session.age = 18;
        res.send('登录成功')
    }
})

//取信息
app.get('/index', (req, res) => {
    //取信息
    console.log(req.session);
    res.send('ok')
})

